package com.k8.rpc.invoke.invoker;

import com.k8.common.factroy.BeanFactory;
import com.k8.rpc.exchange.Exchange;
import com.k8.rpc.invoke.Invoker;
import com.k8.rpc.invoke.InvokerBuilder;
import com.k8.rpc.url.URL;

import java.util.Map;

/**
 * @Author: k8
 * @CreateTime: 2025-03-26
 * @Version: 1.0
 */
public class DefaultInvokerBuilder implements InvokerBuilder {


    @Override
    public <T> Invoker<T> buildProvider(Class<T> type, T target, URL url, BeanFactory beanFactory) {
        return new ProviderInvoker<>(url, type, target);
    }

    /**
     * {@link com.k8.rpc.directory.DynamicDirectory#judgeInstanceIsAliveAndCreateNew(Map, URL)}
     * 中通过subUrl创建consumerUrl
     *
     * @param type
     * @param subUrl
     * @param <T>
     * @return
     */
    @Override
    public <T> Invoker<T> buildConsumer(Class<T> type, URL subUrl, Exchange exchange) {
        //
        return new ConsumerInvoker<>(type, subUrl, exchange);
    }


}
